package netty.demo.nio.byteBuffer;

import java.nio.ByteBuffer;

/**
 * @author Zed
 * @description
 * @date 2022/10/20 22:45
 */
public class testByteBufferRead {
    public static void main(String[] args) {
        ByteBuffer byteBuffer = ByteBuffer.allocate(10);
        byteBuffer.put(new byte[]{'a', 'b', 'c', 'd'});
        byteBuffer.flip();
        //pos位置到达4
        System.out.println(byteBuffer.get(new byte[4]));
        //rewind从头开始读 将pos位置重置为0
        byteBuffer.rewind();
        System.out.println((char) byteBuffer.get());
    }
}
